package cn.sm1234.controller;

import cn.sm1234.domain.Customer;
import cn.sm1234.service.CustomerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping("/customer")
public class CustomerController {

    // 用resource注解自动生成对象， 指定为应用程序中的一个资源组件类。当前类初始化时， 会注入该类
    @Resource
    private CustomerService customerService;

    // 跳转到input页面
    @RequestMapping("/input")
    public String input(){
        return  "input";
    }

    @RequestMapping("/save")
    public String save(Customer customer){
        customerService.save(customer);
        return "success";
    }
}
